<?php
session_start();
$mod_title="авторизация";
$mod_status="on";
if($mod_status=="on")
{
function mod_body($auth,$adminauth)
{
include "server_config.php";
if("$_GET[dox]"=="" && empty($_GET['sdo']))
{
echo "
<form method='POST' action='?do=login&dox=go&cd=0x0001'>
логин:<br>
<input type='text' name='login' size='15'><br>
пароль:<br>
<input type='password' name='pass' size='15'><br>
сервер:<br>
<select name='server'>
";
$query = "SELECT * FROM servers ORDER BY id";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($idZ,$serverZ,$dbZ,$rootZ,$passZ,$nameZ) = mysql_fetch_row($cat))
{
echo "<option value='$nameZ'>$nameZ</option>";
}
echo "
</select><br>
запомнить пароль? 
<input type='checkbox' value='ok' name='check' checked><br>
<input type='submit' value='войти'><br>
</form>
";
$authx="no";
$adminauth="no";
$login="$_COOKIE[login]";
$passw="";
$perms="";
$adminauth="no";
$rt="no";
$query = "SELECT * FROM users WHERE login='$login'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$login,$pass,$mail,$reg,$class,$m,$h,$z,$s,$mon,$gold,$pms,$lvl,$ava,$ban,$online) = mysql_fetch_row($cat))
{
$rt=$reg;
$perms=$pms;
$passw=$pass;
}
if($passw !="" && $_COOKIE['pass'] !="" && $_COOKIE['pass']==$passw && $rt=="ok")
{
$authx="ok";
}
if($rt!="ok" && $_COOKIE['pass'] !="" && $_COOKIE['pass']==$passw)
{
$authx="reg";
}
if($authx=="ok")
{
echo "ваша старая сесия не потеряна.<br>хотите использовать её?<br>
<a href='?do=game/index'>да</a>|<a href='?do=game/out'>нет</a><br>
";
}
else
{
$_COOKIE['login']="";
$_COOKIE['pass']="";
}
}
else if($_GET['sdo']=="vklogin")
{
if(!empty($_COOKIE['auth_key']))
{
$log="";
$query = "SELECT * FROM vklogin WHERE auth='$_COOKIE[auth_key]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($auth,$login) = mysql_fetch_row($cat))
{
$log=$login;
}
if($log !="")
{
echo "
<form method='POST' action='?do=login&dox=go&cd=0x0001'>
<input type='hidden' name='login' size='15' value='$log'>
<input type='hidden' name='pass' size='15' value='$_COOKIE[auth_key]'>
<input type='submit' value='Войти в игру!'><br>
</form>
";
}
}
}
else
{
$authx="no";
$adminauth="no";
$login="$_POST[login]";
$passw="";
$perms="";
$adminauth="no";
$rt="no";
$query = "SELECT * FROM users WHERE login='$login'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$login,$pass,$mail,$reg,$class,$m,$h,$z,$s,$mon,$gold,$pms,$lvl,$ava,$ban,$online) = mysql_fetch_row($cat))
{
$rt=$reg;
$perms=$pms;
$passw=$pass;
}
if($passw !="" && $_POST['pass'] !="" && $_POST['pass']==$passw && $rt=="ok")
{
$authx="ok";
}
if($rt!="ok" && $_POST['pass'] !="" && $_POST['pass']==$passw)
{
$authx="reg";
}
if($authx=="ok")
{
echo "<html>
<head>
<meta http-equiv='Refresh' content='0;URL=index.php?do=game/index'>
</head>
</html>";
}
else if($authx=="reg")
{
$_COOKIE['login']="";
$_COOKIE['pass']="";
echo "
Ваш аккаунт не подтверждён!<br>
";
}
else
{
$_COOKIE['login']="";
$_COOKIE['pass']="";
echo "
логин или пароль неверные!<br>
";
}
}
include "data/button.php";
}
}
else
{
function mod_body($auth,$adminauth)
{
echo "мод выключен администратором!<br>";
}
}
?>